package com.webserver.controller;

import com.webserver.entity.User;

import java.io.*;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.attribute.BasicFileAttributes;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;

public class FileTime {



    public static void main(String[] args) {
        User user = new User();
        File userDir = new File("./users");
        String line =  userDir+"/"+userDir.getName();
        System.out.println(line);

        File file = new File("./users");
        File[] files = file.listFiles();
        for (File userFile : files) {
            String name = userFile.getName();
            System.out.println(name);

            SimpleDateFormat dateFormat = new SimpleDateFormat("YYYY-MM-dd");
            java.nio.file.attribute.FileTime t = null;
            try {
                t = Files.readAttributes(Paths.get(userDir + "/" + name), BasicFileAttributes.class).creationTime();
            } catch (Exception e) {
                e.printStackTrace();
            }
            String time = dateFormat.format(t.toMillis());
            System.out.println(time);
        }
    }
}
